<template>
  <div>
    <el-table
      :data="tableData"
      border
      stripe
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号"
        width="180"
        row-class-name="">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话"
        width="180">
      </el-table-column>
      <el-table-column
        prop="eamil"
        label="邮箱"
        width="180">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="日期"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
    </el-table>
    <!-- 分页-->
    <el-pagination
      :page-sizes="[5, 10, 15, 20]"
      align="right"
      background
      layout="sizes,prev, pager,next"
      :total="total"
      :page-size="pagesize"
      :current-page="crrentpage"
      @current-change="goCurrentPage"
      @size-change="goPageSize">
    </el-pagination>
  </div>
</template>

<script>

import axios from "axios";
export default {
  data () {

    return {

      crrentpage:1,
      pagesize:5,
      total:110,
      tableData: []
    }
  },
  methods:{
    goCurrentPage(crrentpage){
      this.crrentpage = crrentpage;
      this.list()
    },
    goPageSize(pagesize){
      this.pagesize = pagesize;
      this.list()
    }
    ,list(){
      // 发送ajax请求到后台获取数据
        axios.post("/user/list",{"currentPage":this.crrentpage,"pageSize":this.pagesize})
          // 接收返回值对其操作
      .then(result=>{
          this.tableData = result.data.data;
          this.total = result.data.totals;
      })// 有异常情况时
      .catch(error=>{
        console.log(error)
        alert("系统错误")
      })
    }
  },
  mounted() {
    this.list();
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
